#ifndef _BUFFERED_READER_H_
#define _BUFFERED_READER_H_

#include <string>
using std::string;
/**
 * Class to read data from a socket
 * 
 * @author Trent Zhou
 */
class BufferedReader
{
public:
    /**
     * 
     * @param sock
     */
    BufferedReader(int sock);
    virtual ~BufferedReader();
          /**
           * Default buffer size
           */
    enum {BUFFER_SIZE = 400};

    /**
     * Read a character from buffer
     * 
     * @param chr    [out] character output
     * 
     * @return true for OK; false for failure
     */
    bool getChar(char& chr);
    /**
     * Read a line from buffer
     * 
     * @param str    [out] place to hold output line
     * 
     * @return true for OK; false for failure
     */
    bool getLine(string& str);
private:
    int m_sock;
    char m_buffer[BUFFER_SIZE];
    size_t m_charCountInBuffer;
    size_t m_indexInBuffer;
};

#endif

